package com.thinkgem.jeesite;

import com.thinkgem.jeesite.common.utils.DateUtils;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.mzb.entity.MzbYearcheckView;
import com.thinkgem.jeesite.modules.mzb.service.MzbYearcheckViewService;
import com.thinkgem.jeesite.weixin.utils.NoticeTemplateMsgUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@Lazy(false)
public class Z_MyTask1 {
    @Autowired
    MzbYearcheckViewService mzbYearcheckViewService ;

    @Autowired
    NoticeTemplateMsgUtil noticeTemplateMsgUtil;
    @Scheduled(cron="0 * * 30 6 ? ")//6月31号触发
    public void taskCycle(){

        List<MzbYearcheckView> mzbYearcheckViews =  mzbYearcheckViewService.findList(new MzbYearcheckView());
        for (MzbYearcheckView  mzbYearcheckView : mzbYearcheckViews) {
            if (StringUtils.isBlank(mzbYearcheckView.getOpenid()) && StringUtils.equals(mzbYearcheckView.getDelFlag(),"0")) {
                mzbYearcheckView.setDelFlag("2");
                mzbYearcheckViewService.save(mzbYearcheckView);
                continue;
            }
            noticeTemplateMsgUtil.send3Word(mzbYearcheckView.getOpenid(), mzbYearcheckView.getUserName() + "您好,您收到一条来自海沧民政局的通知","年检申报-预警通知", DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss") , "请尽快登录后台进行年检材料的提交","");
        }
    }
}